/*
 * align.cpp
 *
 *  Created on: 2011-09-06
 *      Author: pawel
 */
#include"align.h"
#include"backtrack/backTrack.h"
#include"backtrack/alignStrings.h"
#include<Bpp/Seq/Sequence.h>
align::align(bpp::BasicSequence* query,bpp::BasicSequence* &compSeq,const btrack::alignStrings &bal,const int score)
:queryPtr(query),compSequenceName(compSeq->getName()),btrackedAlign(bal),lettersFreq(compSeq),score(score),identity(bal.getIdentity())
,similarity(bal.getSimilarity()),
gaps(bal.getGaps()),eValue(0.0),zScore(0.0),bits(0.0)
{

if(compSeq!= NULL){
	delete compSeq;
	compSeq = NULL;
}
}
align::~align(){
}
double align::getIdentity()const{return identity;}
double align::getSimilarity()const{return similarity;}
double align::getGaps()const{return gaps;}
double align::getEValue()const{return eValue;}
double align::getZScore()const{return zScore;}
double align::getBits()const{return bits;}
int align::getScore()const{return score;}
bool align::isLocal()const{return local;}
bpp::BasicSequence* align::getQuerySeqPtr()const{return queryPtr;}
std::string& align::getCompSeqName(){return compSequenceName;}

bool align::compareScore(align *a,align *b){
	return a->score >= b->score;
}
bool align::compareIdentity(align *a,align *b){
	return a->identity >= b->identity;
}
bool align::compareSimilarity(align *a,align *b){
	return a->similarity >= b->similarity;
}
bool align::compareGaps(align *a,align *b){
	return a->gaps <= b->gaps;
}
bool align::compareEValue(align *a,align *b){
	return a->eValue <= b->eValue;
}
bool align::compareZScore(align *a,align *b){
	//TODO unsure
	return a->zScore >= b->zScore;
}
bool align::compareBits(align *a,align *b){
	return a->bits >= b->bits;
}
